package util;

import java.util.Comparator;

import jmetal.core.Solution;

public class MySolutionComparator implements Comparator<Solution> {

	@Override
	public int compare(Solution o1, Solution o2) {
		if(o1 instanceof Solution && o2 instanceof Solution)
		{			
			Solution s1 = o1;
			Solution s2 = o2;
			
			for(int i = 0; i < s1.getProblem().getNumberOfObjectives(); i++)
			{
				if(s1.getObjective(i) < s2.getObjective(i))
				{
					return -1;
				}
				if(s1.getObjective(i) > s2.getObjective(i))
				{
					return 1;
				}
			}
		}
		
		return 0;
	}
}
